package LeetCode.interview;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import LeetCode.interview._101_Symmetric_Tree.TreeNode;
import LeetCode.interview._141_Linked_List_Cycle.ListNode;
import sun.tools.jar.resources.jar;
import util.LogUtils;
import util.TraverseUtils;

/*
 * 
原题
		　Given a positive integer, return its corresponding column title as appear in an Excel sheet.
	
	For example:
	
	    1 -> A
	    2 -> B
	    3 -> C
	    ...
	    26 -> Z
	    27 -> AA
	    28 -> AB 
题目大意
　	　   
解题思路
		其实就是10禁止转26进制，只不过A是从1开始， 而不是0
 * @Date 2017-09-28 00：59
 */
public class _168_Excel_Sheet_Column_Title {

    public String convertToTitle(int n) {
    	
    	String rs = "";
    	while (n != 0) {
    		int d = (n-1) % 26;
    		rs += Character.valueOf((char)('A'+d));
    		LogUtils.print(rs);
    		n = (n-1) / 26;
    	}  
    	String rs2 = "";
   
    	//反转字符串
        for (int i = rs.length() - 1; i >= 0; i--) {  
            
        	rs2 += rs.charAt(i);  
  
        }  
        return rs2;
    }

	public static void main(String[] args) {
		_168_Excel_Sheet_Column_Title obj = new _168_Excel_Sheet_Column_Title();
		LogUtils.println("结果", obj.convertToTitle(28));
	}

}
